clear all

*********************************************
****   Description   ************************
*********************************************

*This program analyzes the relationship between persuasion and subsequent account openings at the Freedman's Savings Bank, generating "Table 8. Persuasion and Deposit Collection - Panel Analysis across Branches of the Freedman’s Savings Bank".  


*********************************************
****   Weekly analysis - Advertising ******** 
*********************************************
 global cluster mo_date

use  "$Data/AdvertisingAccounts_WeeklyPanel_December2024.dta", clear 

***Generate Variables
gen ln_accounts=ln(num_account)
gen ln_accounts_black =ln(num_account_black)
gen share_black =num_account_black/num_account

***Regressions
gen sum_persuasion_lag=.


*All accounts
foreach var of varlist    h_AllPersuasion_tfidf persuasion_tot   {

replace sum_persuasion_lag=lag_`var'

reghdfe ln_accounts  sum_persuasion_lag sum_week_lag [pw= black_pop_1870],  absorb(year branch ) cluster($cluster)   
eststo

}


*Black accounts
foreach var of varlist h_AllPersuasion_tfidf persuasion_tot   {

replace sum_persuasion_lag=lag_`var'

reghdfe ln_accounts_black  sum_persuasion_lag sum_week_lag [pw= black_pop_1870] ,  absorb(year branch ) cluster($cluster)   
eststo

}

*Share Black
foreach var of varlist    h_AllPersuasion_tfidf persuasion_tot   {

replace sum_persuasion_lag=lag_`var'

reghdfe share_black  sum_persuasion_lag sum_week_lag ,  absorb(year  branch) cluster($cluster) 
eststo


}

esttab , keep(sum_week_lag sum_persuasion_lag)  ///
b(%10.2f) se(%10.2f)  ///
starlevels(* .10 ** .05 *** .01) nolegend ///
nonumbers ///
nonotes mlabels(none) /// 
stats(N r2 r2_p, fmt(%9.0fc %9.2f) label( "Observations" "$ R^{2} $"  "$P-R^{2} $" ))

 